/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.skipass;

import java.util.Objects;

/**
 *
 * @author vlad
 */
public abstract class Skipass {
    
    private final long uuid;
    protected final SkipassSystem system;

    protected Skipass(final SkipassSystem system) {
        this.system = system;
        uuid = system.generateNextId();
    }

    public abstract boolean validate();

    public abstract void useCard();

    public boolean isBlocked() {
        return system.checkBlock(this);
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Skipass)) {
            return false;
        }
        Skipass sp = (Skipass) obj;
        return sp.getUuid() == this.getUuid();
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + Objects.hashCode(this.getUuid());
        return hash;
    }

    /**
     * @return the uuid
     */
    long getUuid() {
        return uuid;
    }
    
}
